package com.workflow.workflowproject.entity.table;

import com.mybatisflex.core.query.QueryColumn;
import com.mybatisflex.core.table.TableDef;

import java.io.Serial;

/**
 *  表定义层。
 *
 * @author sht05
 * @since 2024-11-04
 */
public class FlowDataTableDef extends TableDef {

    @Serial
    private static final long serialVersionUID = 1L;

    /**
     * 
     */
    public static final FlowDataTableDef FLOW_DATA = new FlowDataTableDef();

    /**
     * 流程业务ID
     */
    public final QueryColumn ID = new QueryColumn(this, "id");

    /**
     * 是否存在
     */
    public final QueryColumn EXIST = new QueryColumn(this, "exist");

    /**
     * 状态（0、待审批；1、流程通过；2、流程驳回；3、流程暂存；）
     */
    public final QueryColumn STATE = new QueryColumn(this, "state");

    /**
     * 流程定义id
     */
    public final QueryColumn FLOW_ID = new QueryColumn(this, "flow_id");

    /**
     * 创建时间
     */
    public final QueryColumn CREATE_TIME = new QueryColumn(this, "create_time");

    /**
     * 修改时间
     */
    public final QueryColumn UPDATE_TIME = new QueryColumn(this, "update_time");

    /**
     * 流程实例ID
     */
    public final QueryColumn PROCESS_INSTANCE_ID = new QueryColumn(this, "process_instance_id");

    /**
     * 所有字段。
     */
    public final QueryColumn ALL_COLUMNS = new QueryColumn(this, "*");

    /**
     * 默认字段，不包含逻辑删除或者 large 等字段。
     */
    public final QueryColumn[] DEFAULT_COLUMNS = new QueryColumn[]{ID, FLOW_ID, PROCESS_INSTANCE_ID, STATE, CREATE_TIME, UPDATE_TIME, EXIST};

    public FlowDataTableDef() {
        super("", "t_com_flow_data");
    }

    private FlowDataTableDef(String schema, String name, String alisa) {
        super(schema, name, alisa);
    }

    public FlowDataTableDef as(String alias) {
        String key = getNameWithSchema() + "." + alias;
        return getCache(key, k -> new FlowDataTableDef("", "t_com_flow_data", alias));
    }

}
